import { h, render } from 'vue'
import Toast from './toast.vue'

interface Options {
	message: string
	duration?: number
}

type Config = Options | string

export default function createToast(config: Config) {
	let props: Options = {} as Options
	const container = document.createElement('div')
	if (typeof config === 'string') {
		props.message = config
	} else {
		props = config
	}
	const vNode = h(Toast, props)
	render(vNode, container)
	document.body.appendChild(container)
}
